package com.action.hurt
{
	import com.action.ActionHurt;
	import com.action.ActionStand;
	import com.resource.unit.ActionUnit;
	import com.stage.item.Player;
	
	/**
	 * 控制类状态，角色不能控制
	 * 击晕，昏睡等受伤状态，这些状态是持续一段时间，角色不受控制
	 */
	public class ActionHurtState extends ActionHurt
	{
		protected var _lastTime:Number = 0;
		protected var _startTime:Number = 0;
		
		public function ActionHurtState(player:Player, data:Object)
		{
			super(player, data);
		}
		
		public override function start(dir:int=1):void{
			_player.view.isStop = false;
			_actFinish = false;
			
			// TODO 根据技能，设置击退和击飞效果
			_player.act = ActionUnit.HURT; // 受伤动作应该也有不同
			_lastTime = 5000;
			_startTime = (new Date).time;
			
			super.start(dir);
		}
		
		protected override function enterFrame():void{
			checkGround();
			if((new Date).time >= _lastTime + _startTime){
				// 时间到，状态结束
				_player.action = new ActionStand(player);
				_player.action.start(_player.dir);
			}
		}
		
		public override function end():void{
			_player.view.isStop = false;
			super.end();
		}
	}
}